package cn.iocoder.yudao.module.member.dal.mysql.vehicleinfo;


import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.member.dal.dataobject.vehicleinfo.VehicleInfoDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.member.controller.admin.vehicleinfo.vo.*;

import java.util.List;

/**
 * 车辆管理 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface VehicleInfoMapper extends BaseMapperX<VehicleInfoDO> {

    default PageResult<VehicleInfoDO> selectPage(VehicleInfoPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<VehicleInfoDO>()
                .eqIfPresent(VehicleInfoDO::getCarCode, reqVO.getCarCode())
                .eqIfPresent(VehicleInfoDO::getDeptId, reqVO.getDeptId())
                .eqIfPresent(VehicleInfoDO::getCarType, reqVO.getCarType())
                .eqIfPresent(VehicleInfoDO::getDeviceCode, reqVO.getDeviceCode())
                .eqIfPresent(VehicleInfoDO::getDeviceType, reqVO.getDeviceType())
                .eqIfPresent(VehicleInfoDO::getDeviceFactory, reqVO.getDeviceFactory())
                .eqIfPresent(VehicleInfoDO::getSimCode, reqVO.getSimCode())
                .eqIfPresent(VehicleInfoDO::getSimCodeFactory, reqVO.getSimCodeFactory())
                .betweenIfPresent(VehicleInfoDO::getActivateTime, reqVO.getActivateTime())
                .betweenIfPresent(VehicleInfoDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(VehicleInfoDO::getUpdater, reqVO.getUpdater())
                .orderByDesc(VehicleInfoDO::getId));
    }

    default List<VehicleInfoDO> selectList(VehicleInfoPageReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<VehicleInfoDO>()
                .eqIfPresent(VehicleInfoDO::getCarCode, reqVO.getCarCode())
                .eqIfPresent(VehicleInfoDO::getDeptId, reqVO.getDeptId())
                .eqIfPresent(VehicleInfoDO::getCarType, reqVO.getCarType())
                .eqIfPresent(VehicleInfoDO::getDeviceCode, reqVO.getDeviceCode())
                .eqIfPresent(VehicleInfoDO::getDeviceType, reqVO.getDeviceType())
                .eqIfPresent(VehicleInfoDO::getDeviceFactory, reqVO.getDeviceFactory())
                .eqIfPresent(VehicleInfoDO::getSimCode, reqVO.getSimCode())
                .eqIfPresent(VehicleInfoDO::getSimCodeFactory, reqVO.getSimCodeFactory())
                .betweenIfPresent(VehicleInfoDO::getActivateTime, reqVO.getActivateTime())
                .betweenIfPresent(VehicleInfoDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(VehicleInfoDO::getUpdater, reqVO.getUpdater())
                .orderByDesc(VehicleInfoDO::getId));
    }

}